#ifndef __W25QXX_H__
#define __W25QXX_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "main.h"
#include "spi.h"

	
/*片选控制宏*/
#define CS_LOW()    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_RESET)
#define CS_HIGH()   HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_SET)

/*flash参数*/
#define W25Q64_SECTOR_SIZE      4096    
#define LED_STATUS_ADDR         0x000000 

/*函数声明*/

/// @brief 初始化falsh
/// @param dummy
/// @return void 
void w25qxx_init(void);
/// @brief 对flash芯片发送写使能
/// @param cmd
/// @return void
void w25qxx_write_enable(void);
/// @brief  检测并等待写入flash芯片
/// @param  w25qxx_read_status_reg
/// @return void
void w25qxx_wait_busy(void);
/// @brief 扇区擦除函数
/// @param addr
/// @return void
void w25qxx_sector_erase(uint32_t addr);
/// @brief flash芯片页写入
/// @param addr 
/// @param data 
/// @param len
/// @return  void
void w25qxx_page_write(uint32_t addr, uint8_t *data, uint16_t len);
/// @brief 发送读操作的信号
/// @param addr 
/// @param buf 
/// @param len 
/// @return  void
void w25qxx_read(uint32_t addr, uint8_t *buf, uint16_t len);
/// @brief 读取flash中寄存器的数据
/// @param  status
/// @return status  //表示为返回led的状态
uint8_t w25qxx_read_status_reg(void);

#ifdef __cplusplus
}
#endif

#endif
